package com.zeropol2.anyquestion.component.ui.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zeropol2.anyquestion.R;

/**
 * 이미지와 텍스트가 있는 버튼
 * @author zeropol2
 *
 */
public class ImageTextButton extends LinearLayout {
	private Context mContext;
	private LayoutInflater mInflater;
	private LinearLayout mLayout;
	private ImageView mImgView;
	private TextView mTextView;
	
	public ImageTextButton(Context context) {
		super(context);
		mContext = context;
		init();
	}

	public ImageTextButton(Context context, AttributeSet attrs) {
		super(context, attrs);
		mContext = context;
		init();
	}
	
	private void init() {
		mInflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		mLayout = (LinearLayout) mInflater.inflate(R.layout.image_text_button, this);
		mImgView = (ImageView)mLayout.findViewById(R.id.image_text_button_image);
		mTextView = (TextView)mLayout.findViewById(R.id.image_text_button_text);

	}
	
	
	/**
	 * 이미지 셋팅
	 * @param img
	 */
	public void setImage(Drawable img) {
		mImgView.setImageDrawable(img);
	}
	

	/**
	 * 텍스트 셋팅
	 * @param text
	 */
	public void setText(String text) {
		mTextView.setText(text);
	}
	
	
	/**
	 * 텍스트 반환
	 * @return
	 */
	public String getText() {
		return mTextView.getText().toString();
	}
	
}
